docs: rewrite Java template tutorial to AsyncAPI v3#2029
docs: rewrite Java template tutorial to AsyncAPI v3#2029wei123-web wants to merge 7 commits intoasyncapi:masterfrom
Conversation
|
📝 WalkthroughWalkthroughUpdated the Java template tutorial to AsyncAPI v3 and generator v2: examples, template wiring, and TopicFunction now use AsyncAPI v3 operations and server APIs; example YAML and package.json updated; duplicated log text and EOF newline fixes applied. (≤50 words) Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
🚀 Docs preview deployed |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
apps/generator/docs/generator-template-java.md (1)
318-318: Wording drift: this should reference operations, not channels.Since this section migrates to AsyncAPI v3 operations, “regardless of the number of channels” is misleading here.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/generator/docs/generator-template-java.md` at line 318, The sentence currently references "channels" but this section is about AsyncAPI v3 operations; update the wording around the `TopicFunction` description to reference "operations" (or "the number of operations in the AsyncAPI v3 document") instead of "channels" so it accurately reflects that the reusable component applies regardless of operation count in the asyncAPI v3 document.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/generator/docs/generator-template-java.md`:
- Line 393: BROKER_URL is being set to server.host() which yields "host:port"
but the Paho MQTT client requires a URI with a scheme; update the assignment
that sets the static constant BROKER_URL (and the server.host() usage in the
server configuration) to prepend an appropriate scheme such as "tcp://" (e.g.,
"tcp://" + server.host()) so the value becomes a valid URI like
"tcp://test.mosquitto.org:1883" before it is used by the client.
- Around line 355-357: The template is filtering receive operations which misses
AsyncAPI operations with action: send; update getTopicsFromOperations to use
operations.filterBySend() when generating publish/send methods (replace
operations.filterByReceive() with operations.filterBySend()), and apply the same
change to other occurrences where publish methods are derived (the other places
using operations.filterByReceive() for send-method generation) so generated
TestClient sendTemperatureDrop/Rise methods match the document's action: send
operations.
---
Nitpick comments:
In `@apps/generator/docs/generator-template-java.md`:
- Line 318: The sentence currently references "channels" but this section is
about AsyncAPI v3 operations; update the wording around the `TopicFunction`
description to reference "operations" (or "the number of operations in the
AsyncAPI v3 document") instead of "channels" so it accurately reflects that the
reusable component applies regardless of operation count in the asyncAPI v3
document.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 25edfbe6-b065-444b-9743-ce85e40aeb58
📒 Files selected for processing (1)
apps/generator/docs/generator-template-java.md
|
/u |
| function getTopics(channels) { | ||
| const channelsCanSendTo = channels | ||
| function getTopicsFromOperations(operations) { | ||
| const receiveOperations = operations.filterBySend(); |
There was a problem hiding this comment.
operations if you look into line 381 are already filtered correct by receive, so not filter by send again makes no sense, will always be empty, no?
derberg
left a comment
There was a problem hiding this comment.
please also check Java - package.json file section and make sure generator apversion and compatibility is set correctly
|
and please make sure that your changes to AsyncAPI YAML are exactly the same as in the similar tutorial but python one |
|
Thanks for the review @derberg! Will fix all the issues shortly |
…to receive in YAML
…123-web/generator into docs/update-java-template-v3
|
There was a problem hiding this comment.
♻️ Duplicate comments (1)
apps/generator/docs/generator-template-java.md (1)
356-357:⚠️ Potential issue | 🔴 CriticalOperation direction is inconsistent, so generated
send...methods will be missing.At Line 356, the tutorial filters with
operations.filterBySend(), but at Line 473 and Line 477 both operations areaction: receive. This produces no topic methods, while Line 503 and Line 506 callsendTemperatureDrop/Rise, so the tutorial flow breaks.Suggested fix
operations: temperatureDrop: - action: receive + action: send channel: $ref: '#/channels/temperature~1dropped' temperatureRise: - action: receive + action: send channel: $ref: '#/channels/temperature~1risen'#!/bin/bash # Verify direction mismatch between filter and AsyncAPI operation actions in this tutorial file. set -euo pipefail FILE="apps/generator/docs/generator-template-java.md" echo "== filter usage ==" rg -n "filterBySend|filterByReceive" "$FILE" echo echo "== operation actions in YAML snippet ==" rg -n "operations:|temperatureDrop:|temperatureRise:|action:" "$FILE" -A3 -B1 echo echo "Expected: if filterBySend is used for method generation, operations should use action: send."Based on learnings: “AsyncAPI 3.0.0 specification introduces significant structural changes from 2.x: operations become top-level elements with action property (send/receive) and references to channels.”
Also applies to: 472-479, 503-507
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/generator/docs/generator-template-java.md` around lines 356 - 357, The tutorial uses operations.filterBySend() but assigns it to receiveOperations, and the AsyncAPI examples define operations with action: receive, so generated send... methods are missing; update the usage to match intent by either changing the filter to operations.filterByReceive() (if you want receive operations) or updating the sample YAML operations' action values to send (if you intend to generate send methods), and ensure the variable name receiveOperations and any subsequent calls to sendTemperatureDrop/Rise or send... methods are consistent with the chosen filter and operation action.
🧹 Nitpick comments (1)
apps/generator/docs/generator-template-java.md (1)
349-350: Comments/identifier naming drift from behavior; please align wording.
receiveOperations(Line 356) actually storesfilterBySend()results, and comments at Line 349-350 / Line 380 still talk about receive operations. This is confusing in a tutorial and easy to copy incorrectly.Suggested cleanup
- * This function returns a list of objects, one for each receive operation. + * This function returns a list of objects, one for each send operation. ... - const receiveOperations = operations.filterBySend(); + const sendOperations = operations.filterBySend(); ... - receiveOperations.forEach((op) => { + sendOperations.forEach((op) => {Based on learnings: “Update relevant Generator documentation to accurately reflect PR changes introduced.”
Also applies to: 356-360, 380-380
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/generator/docs/generator-template-java.md` around lines 349 - 350, The comments in the generator-template-java.md are misleading: the variable receiveOperations actually stores results from filterBySend(), i.e., send operations; update all relevant comment text that mentions "receive operations" (references: receiveOperations, filterBySend()) to correctly say "send operations" or "filtered send operations" and adjust the descriptive lines (the block describing name/operationId and any nearby bullets) so they reflect that the list contains send-operation objects rather than receive-operation objects.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@apps/generator/docs/generator-template-java.md`:
- Around line 356-357: The tutorial uses operations.filterBySend() but assigns
it to receiveOperations, and the AsyncAPI examples define operations with
action: receive, so generated send... methods are missing; update the usage to
match intent by either changing the filter to operations.filterByReceive() (if
you want receive operations) or updating the sample YAML operations' action
values to send (if you intend to generate send methods), and ensure the variable
name receiveOperations and any subsequent calls to sendTemperatureDrop/Rise or
send... methods are consistent with the chosen filter and operation action.
---
Nitpick comments:
In `@apps/generator/docs/generator-template-java.md`:
- Around line 349-350: The comments in the generator-template-java.md are
misleading: the variable receiveOperations actually stores results from
filterBySend(), i.e., send operations; update all relevant comment text that
mentions "receive operations" (references: receiveOperations, filterBySend()) to
correctly say "send operations" or "filtered send operations" and adjust the
descriptive lines (the block describing name/operationId and any nearby bullets)
so they reflect that the list contains send-operation objects rather than
receive-operation objects.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: bae6669b-c952-4bf2-8199-e04a021f0b47
📒 Files selected for processing (1)
apps/generator/docs/generator-template-java.md
|
hello @derberg fixed all three issues: |



Description
Rewrites the "Creating a template – Java" tutorial to use AsyncAPI v3.
Changes made:
url:withhost:in servers sectiongetTopicstogetTopicsFromOperationsindex.jsto useasyncapi.operations().filterByReceive()server.host()Related issue
Resolves #1828
Summary by CodeRabbit